import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { $t } from '@vben/locales';

import { z } from '#/adapter/form';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'dictType',
    label: $t('system.dictType.dictType'),
  },
];

export const columns: () => VxeGridProps['columns'] = () => [
  { type: 'checkbox', width: 60 },
  {
    title: $t('system.dictType.dictName'),
    field: 'dictName',
  },
  {
    title: $t('system.dictType.dictType'),
    field: 'dictType',
  },
  {
    title: $t('common.remark'),
    field: 'remark',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: $t('common.operator'),
    width: 140,
  },
];

export const modalSchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
    fieldName: 'id',
    label: 'id',
  },
  {
    component: 'Input',
    fieldName: 'dictName',
    label: $t('system.dictType.dictName'),
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'dictType',
    help: $t('system.dictType.dictTypeHelp'),
    label: $t('system.dictType.dictType'),
    rules: z
      .string()
      .regex(/^[a-z_]+$/i, { message: $t('system.dictType.dictTypeRule') }),
  },
  {
    component: 'Textarea',
    fieldName: 'remark',
    formItemClass: 'items-baseline',
    label: $t('common.remark'),
  },
];
